import {BasicColumn, FormSchema} from '@/components/table';
import {render} from "@/hooks/render/renderUtils";
import {Api} from './version.api';
import {RenderType} from '@pkg/setting';
export const columns: BasicColumn[] = [
  {
    title: '版本标题',
    dataIndex: 'verTitle',
    width: 200,
  },
  {
    title: '版本号',
    dataIndex: 'verNo',
    width: 100,
  },
  {
    title: '版本类型',
    dataIndex: 'verCode',
    width: 100,
    dictData: [
      {label: '安卓', value: 1},
      {label: '苹果', value: 2}
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '强制更新',
    dataIndex: 'forceUpdate',
    width: 80,
    sorter:true,
    renderApi: Api.setState,
    rowKey: 'versionId',
    customRender: render.renderSwitch
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [];

export const formSchema: FormSchema[] = [
  {
    label: '标题',
    field: 'verTitle',
    component: 'Input',
    required: true,
  },
  {
    label: '版本号',
    field: 'verNo',
    component: 'Input',
    required: true,
  },
  {
    label: '设备类型',
    field: 'verCode',
    component: 'Select',
    required: true,
    defaultValue:"1",
    componentProps: {
      options: [
        {label: '安卓', value: "1"},
        {label: '苹果', value: "2"},
      ],
    },
  },
  {
    label: '强制更新',
    field: 'forceUpdate',
    component: 'Switch',
    componentProps:{
      checkedValue: 1,
      unCheckedValue: 0
    }
  },
  {
    label: '更新内容',
    field: 'verContent',
    component: 'InputTextArea',
    required: true,
  },
  {
    label: '文件上传',
    field: 'verUrl',
    component: 'FileUpload',
    required: true,
  },
];
